<script>
import colors from "@/mixins/color.js";
import themeList from "@/utils/theme";
import { config, adornInfo } from "@/servers/servers";
import { HTTP_STATUS } from "./servers/config";
import { setStorage } from "./utils/storage";
export default {
  mixins: [colors],
  onLaunch: async function () {
    // #ifdef MP-WEIXIN
    let menu = wx.getMenuButtonBoundingClientRect();
    this.globalData.menuInfo = menu;
    console.log(menu);
    // #endif

    let theme = await config({
      key: "theme.config",
    });
    if (theme.data.code == HTTP_STATUS.RUSELT_SUCCESS) {
      let data = JSON.parse(theme.data.data);
      if (data.id == 1) {
        //热情红
        uni.setStorageSync("viewColor", themeList.red);
        uni.setStorageSync("colorStatus", themeList.redColor);
        uni.$emit("ok", themeList.red, themeList.redColor);
      }
      if (data.id == 2) {
        //家具橙
        uni.setStorageSync("viewColor", themeList.orange);
        uni.setStorageSync("colorStatus", themeList.orangeColor);
        uni.$emit("ok", themeList.orange, themeList.orangeColor);
      }
      if (data.id == 3) {
        //汽水橙
        uni.setStorageSync("viewColor", themeList.orange2);
        uni.setStorageSync("colorStatus", themeList.orange2Color);
        uni.$emit("ok", themeList.orange2, themeList.orange2Color);
      }
      if (data.id == 4) {
        //生心绿
        uni.setStorageSync("viewColor", themeList.green);
        uni.setStorageSync("colorStatus", themeList.greenColor);
        uni.$emit("ok", themeList.green, themeList.greenColor);
      }
      if (data.id == 5) {
        //极地青
        uni.setStorageSync("viewColor", themeList.qing);
        uni.setStorageSync("colorStatus", themeList.qingColor);
        uni.$emit("ok", themeList.qing, themeList.qingColor);
      }
      if (data.id == 6) {
        //天空蓝
        uni.setStorageSync("viewColor", themeList.blue);
        uni.setStorageSync("colorStatus", themeList.blueColor);
        uni.$emit("ok", themeList.blue, themeList.blueColor);
      }
      if (data.id == 7) {
        //紫罗兰
        uni.setStorageSync("viewColor", themeList.purple);
        uni.setStorageSync("colorStatus", themeList.purpleColor);
        uni.$emit("ok", themeList.purple, themeList.purpleColor);
      }
      if (data.id == 8) {
        //小灰灰
        uni.setStorageSync("viewColor", themeList.ash);
        uni.setStorageSync("colorStatus", themeList.ashColor);
        uni.$emit("ok", themeList.ash, themeList.ashColor);
      }
      console.log(theme);
      console.log("---------主题颜色----------");
    }

    let adorn = await adornInfo();
    if (adorn.data.code == HTTP_STATUS.RUSELT_SUCCESS) {
      let info = adorn.data.data;
      // console.log(info);
      // this.data = JSON.parse(info.config);
      setStorage("customData", JSON.parse(info.config));
      // setTimeout(() => {
      //   this.loadingPage = true;
      // }, 1000);
    }

    console.log("App Launch");
  },
  onShow: function () {
    console.log("App Show");
  },
  onHide: function () {
    console.log("App Hide");
  },
  globalData: {
    menuInfo: {},
    userinfo: {},
    is_authorization: false, //是否有手机号码注册过
    //token:
    //  "bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJpc3N1c2VyIiwiYXVkIjoiYXVkaWVuY2UiLCJyb2xlX25hbWUiOiJ1c2VyIiwidGVuYW50X2lkIjoiMDAwMDAwIiwidXNlcl9pZCI6IjYxODA0IiwidXNlcl9uYW1lIjoiMTUxNzc3ODYwMTUiLCJuaWNrX25hbWUiOiLpmr7lvpfokavoiqYiLCJ0b2tlbl90eXBlIjoiYWNjZXNzX3Rva2VuIiwiYWNjb3VudCI6IjE1MTc3Nzg2MDE1IiwiY2xpZW50X2lkIjoid2FwIiwiZXhwIjoxNzIyNzU4ODA3LCJuYmYiOjE3MjIxNTQwMDd9.mrvqymiSOVhvTwkgSS6__BnDAhxPEFUyP610Wq_tPO8",
    // token: "bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJpc3N1c2VyIiwiYXVkIjoiYXVkaWVuY2UiLCJyb2xlX25hbWUiOiJ1c2VyIiwidGVuYW50X2lkIjoiMDAwMDAwIiwidXNlcl9pZCI6IjE4MTMxNjY0MTEyNzU2NTcyMTgiLCJ1c2VyX25hbWUiOiIxODEyMjcxMTcxMyIsIm5pY2tfbmFtZSI6IuWNjuS7lOecn-W4hSIsInRva2VuX3R5cGUiOiJhY2Nlc3NfdG9rZW4iLCJhY2NvdW50IjoiMTgxMjI3MTE3MTMiLCJjbGllbnRfaWQiOiJ3YXAiLCJleHAiOjE3MjI1MDQ1NjksIm5iZiI6MTcyMTg5OTc2OX0.zoJdcVnflNJiHJ0fA63Vm0O75tLvnc5hidzF8YIn_2w",
    token: "",
  },
};
</script>

<style lang="scss">
@import "uview-ui/index.scss";

/*每个页面公共css */
.flex {
  display: flex;
}

.aitems {
  align-items: center;
}

.between {
  justify-content: space-between;
}

.sa {
  justify-content: space-around;
}

.jcenter {
  justify-content: center;
}

.jend {
  justify-content: flex-end;
}

.wrap {
  flex-wrap: wrap;
}

.column {
  flex-direction: column;
}

.tcenter {
  text-align: center;
}

img,
image {
  display: flex;
}

.ellipsis2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  overflow: hidden;
  /*! autoprefixer: off */
  -moz-box-orient: vertical;
  -webkit-box-orient: vertical;
  /*! autoprefixer: on */
}

.ellipsis1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.w100 {
  width: 100%;
}

.h100 {
  height: 100%;
}

.cfff {
  color: #fff;
}

.f20 {
  font-size: 20rpx !important;
}

.f21 {
  font-size: 21rpx !important;
}

.f22 {
  font-size: 22rpx !important;
}

.f23 {
  font-size: 23rpx !important;
}

.f24 {
  font-size: 24rpx !important;
}

.f25 {
  font-size: 25rpx !important;
}

.f26 {
  font-size: 26rpx !important;
}

.f27 {
  font-size: 27rpx !important;
}

.f28 {
  font-size: 28rpx !important;
}

.f29 {
  font-size: 29rpx !important;
}

.f30 {
  font-size: 30rpx !important;
}

.f31 {
  font-size: 31rpx !important;
}

.f32 {
  font-size: 32rpx !important;
}

.f34 {
  font-size: 34rpx !important;
}

.f36 {
  font-size: 36rpx !important;
}

.f38 {
  font-size: 38rpx !important;
}

.f40 {
  font-size: 40rpx !important;
}

.f42 {
  font-size: 42rpx !important;
}

.f44 {
  font-size: 44rpx !important;
}

.f46 {
  font-size: 46rpx !important;
}

.f48 {
  font-size: 48rpx !important;
}

.f56 {
  font-size: 56rpx !important;
}

.f64 {
  font-size: 64rpx !important;
}

.c666 {
  color: #666;
}

.c333 {
  color: #333;
}

.c999 {
  color: #999;
}

.cE64141 {
  color: #e64141;
}

.c0D6E1A {
  color: #0d6e1a;
}

.fontWeight {
  font-weight: bold;
}

.cccc {
  color: #cccc;
}

.c087FFA {
  color: #087ffa;
}

.cE81A1A {
  color: #e81a1a;
}

.c1F1F1F {
  color: #1f1f1f;
}

.c525252 {
  color: #525252;
}

.c858585 {
  color: #858585;
}
.themeColor {
  color: var(--view-theme) !important;
  // font-weight: bold !important;
}

.avatar-wrapper {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 100%;
  left: 0;
  right: 0;
  top: 0;
  z-index: 99;
  opacity: 0;
}
.cEF8200 {
  color: #ef8200;
}
.c5CCEDD {
  color: #5ccedd;
}
.cDD5C5C {
  color: #dd5c5c;
}
.c020630 {
  color: #020630;
}
.c594807 {
  color: #594807;
}
.c2F1702 {
  color: #2f1702;
}
.cF65B49 {
  color: #f65b49;
}
.c8B949D {
  color: #8b949d;
}
.c00406C {
  color: #00406c;
}
.f80 {
  font-size: 80rpx;
}
.c084E57 {
  color: #084e57;
}
.cf5f5f5 {
  color: #f5f5f5;
}
</style>
